<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>管理员门户 - 银行系统</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.0/font/bootstrap-icons.css">
    <style>
        :root {
            --primary: #1a2a6c;
            --secondary: #b21f1f;
            --accent: #fdbb2d;
        }
        
        body {
            background-color: #f8f9fa;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
        }
        
        .sidebar {
            background: linear-gradient(180deg, var(--primary), #0d1a4a);
            color: white;
            height: 100vh;
            position: fixed;
            padding-top: 20px;
            box-shadow: 3px 0 15px rgba(0,0,0,0.2);
            width: 250px;
            z-index: 100;
        }
        
        .sidebar .nav-link {
            color: rgba(255,255,255,0.85);
            padding: 12px 20px;
            margin: 5px 15px;
            border-radius: 5px;
            transition: all 0.3s;
            display: flex;
            align-items: center;
        }
        
        .sidebar .nav-link:hover, .sidebar .nav-link.active {
            background: rgba(255,255,255,0.15);
            color: white;
        }
        
        .sidebar .nav-link i {
            margin-right: 12px;
            font-size: 1.2rem;
            width: 24px;
            text-align: center;
        }
        
        .main-content {
            margin-left: 250px;
            padding: 20px;
            min-height: 100vh;
        }
        
        .header {
            background: white;
            padding: 15px 25px;
            border-bottom: 1px solid #eee;
            display: flex;
            justify-content: space-between;
            align-items: center;
            box-shadow: 0 2px 10px rgba(0,0,0,0.05);
            position: sticky;
            top: 0;
            z-index: 99;
        }
        
        .stat-card {
            background: white;
            border-radius: 12px;
            box-shadow: 0 4px 12px rgba(0,0,0,0.08);
            padding: 25px;
            margin-bottom: 25px;
            transition: transform 0.3s, box-shadow 0.3s;
            height: 100%;
        }
        
        .stat-card:hover {
            transform: translateY(-7px);
            box-shadow: 0 8px 20px rgba(0,0,0,0.12);
        }
        
        .stat-card i {
            font-size: 2.8rem;
            color: var(--primary);
            margin-bottom: 15px;
        }
        
        .stat-card .number {
            font-size: 2.2rem;
            font-weight: bold;
            margin: 10px 0;
            color: var(--primary);
        }
        
        .stat-card .label {
            color: #6c757d;
            font-size: 0.95rem;
        }
        
        .welcome-section {
            background: linear-gradient(90deg, #ffffff, #f8f9fa);
            border-radius: 15px;
            padding: 30px;
            margin-bottom: 30px;
            box-shadow: 0 6px 15px rgba(0,0,0,0.08);
            border-left: 5px solid var(--primary);
        }
        
        .logout-btn {
            background: var(--primary);
            color: white;
            border: none;
            padding: 8px 20px;
            border-radius: 30px;
            font-weight: 500;
            transition: all 0.3s;
            display: flex;
            align-items: center;
        }
        
        .logout-btn:hover {
            background: #0d1a4a;
            transform: translateY(-2px);
        }
        
        .user-info {
            display: flex;
            align-items: center;
        }
        
        .user-avatar {
            width: 45px;
            height: 45px;
            border-radius: 50%;
            background: var(--primary);
            color: white;
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: bold;
            font-size: 1.2rem;
            margin-right: 12px;
        }
        
        .recent-table th {
            background: #f1f5f9;
            color: var(--primary);
            font-weight: 600;
        }
        
        .income {
            color: #28a745;
            font-weight: 500;
        }
        
        .expense {
            color: #dc3545;
            font-weight: 500;
        }
    </style>
</head>
<body>
    <div class="sidebar">
        <div class="text-center mb-4 px-3">
            <h3>银行管理系统</h3>
            <p class="text-light opacity-75">管理员控制台</p>
        </div>
        
        <ul class="nav flex-column">
            <li class="nav-item">
                <a class="nav-link active" href="{{ url_for('admin_portal') }}">
                    <i class="bi bi-speedometer2"></i> 控制面板
                </a>
            </li>
            <li class="nav-item">
     <a class="nav-link" href="{{ url_for('manage_customers') }}">
        <i class="bi bi-people"></i> 客户管理
       </a>
       </li>
      <li class="nav-item">
    <a class="nav-link" href="{{ url_for('manage_cards') }}">
        <i class="bi bi-credit-card"></i> 银行卡管理
       </a>
     </li>
      <li class="nav-item">
    <a class="nav-link" href="{{ url_for('manage_deposits') }}">
        <i class="bi bi-cash-coin"></i> 存款业务
    </a>
</li>
            </li>
            <li class="nav-item">
                <a class="nav-link" href="#">
                    <i class="bi bi-graph-up"></i> 交易管理
                </a>
            </li>
            <li class="nav-item">
                <a class="nav-link" href="#">
                    <i class="bi bi-file-earmark-bar-graph"></i> 报表统计
                </a>
            </li>
            <li class="nav-item">
                <a class="nav-link" href="#">
                    <i class="bi bi-shield-lock"></i> 安全管理
                </a>
            </li>
            <li class="nav-item">
                <a class="nav-link" href="#">
                    <i class="bi bi-gear"></i> 系统设置
                </a>
            </li>
        </ul>
        
        <div class="mt-auto px-4 py-3 text-center text-light opacity-75" style="font-size: 0.85rem;">
            &copy; 2025 文睿银行系统 v2.0
        </div>
    </div>
    
    <div class="main-content">
        <div class="header">
            <h4 class="mb-0">管理员控制面板</h4>
            <div class="d-flex align-items-center">
                <div class="user-info me-4">
                    <div class="user-avatar">{{ fullname[0] }}</div>
                    <div>
                        <div class="fw-bold">{{ fullname }}</div>
                        <div class="small text-muted">上次登录: {{ login_time }}</div>
                    </div>
                </div>
                <a href="{{ url_for('logout') }}" class="logout-btn">
                    <i class="bi bi-box-arrow-right me-2"></i> 退出系统
                </a>
            </div>
        </div>
        
        <div class="welcome-section">
            <div class="d-flex justify-content-between align-items-center">
                <div>
                    <h2 class="mb-2">欢迎回来，{{ fullname }}！</h2>
                    <p class="text-muted mb-0">以下是系统概览</p>
                </div>
                <div class="text-end">
                    <div class="fs-5 fw-bold text-primary">管理员</div>
                    <div class="badge bg-success">在线</div>
                </div>
            </div>
        </div>
        
        <div class="row g-4">
            <div class="col-md-3">
                <div class="stat-card text-center">
                    <i class="bi bi-people"></i>
                    <div class="number">1,254</div>
                    <div class="label">注册客户</div>
                    <div class="mt-2 small text-success">
                        <i class="bi bi-arrow-up"></i> 本月新增 68 人
                    </div>
                </div>
            </div>
            <div class="col-md-3">
                <div class="stat-card text-center">
                    <i class="bi bi-credit-card"></i>
                    <div class="number">2,568</div>
                    <div class="label">银行卡账户</div>
                    <div class="mt-2 small text-success">
                        <i class="bi bi-arrow-up"></i> 本月新增 142 张
                    </div>
                </div>
            </div>
            <div class="col-md-3">
                <div class="stat-card text-center">
                    <i class="bi bi-cash-coin"></i>
                    <div class="number">¥1.28亿</div>
                    <div class="label">总存款额</div>
                    <div class="mt-2 small text-danger">
                        <i class="bi bi-arrow-down"></i> 较上月减少 2.3%
                    </div>
                </div>
            </div>
            <div class="col-md-3">
                <div class="stat-card text-center">
                    <i class="bi bi-graph-up"></i>
                    <div class="number">5,678</div>
                    <div class="label">今日交易</div>
                    <div class="mt-2 small text-success">
                        <i class="bi bi-arrow-up"></i> 较昨日增加 12.5%
                    </div>
                </div>
            </div>
        </div>
        
        <div class="row mt-4">
            <div class="col-md-8">
                <div class="card border-0 shadow-sm">
                    <div class="card-header bg-white border-0 py-3">
                        <h5 class="mb-0"><i class="bi bi-clock-history me-2"></i> 最近交易记录</h5>
                    </div>
                    <div class="card-body p-0">
                        <div class="table-responsive">
                            <table class="table table-hover align-middle mb-0 recent-table">
                                <thead>
                                    <tr>
                                        <th>时间</th>
                                        <th>卡号</th>
                                        <th>客户</th>
                                        <th>类型</th>
                                        <th>金额</th>
                                        <th>备注</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <tr>
                                        <td>10:25:34</td>
                                        <td>****5678</td>
                                        <td>辜晓城</td>
                                        <td>存款</td>
                                        <td class="income">¥5,000</td>
                                        <td>工资收入</td>
                                    </tr>
                                    <tr>
                                        <td>10:18:12</td>
                                        <td>****4321</td>
                                        <td>苏婉晴</td>
                                        <td>取款</td>
                                        <td class="expense">¥2,000</td>
                                        <td>ATM取款</td>
                                    </tr>
                                    <tr>
                                        <td>09:56:45</td>
                                        <td>****9012</td>
                                        <td>王五</td>
                                        <td>转账</td>
                                        <td class="income">¥1,500</td>
                                        <td>来自张三转账</td>
                                    </tr>
                                    <tr>
                                        <td>09:42:33</td>
                                        <td>****3456</td>
                                        <td>赵六</td>
                                        <td>存款</td>
                                        <td class="income">¥8,000</td>
                                        <td>现金存款</td>
                                    </tr>
                                    <tr>
                                        <td>09:31:27</td>
                                        <td>****7890</td>
                                        <td>钱七</td>
                                        <td>取款</td>
                                        <td class="expense">¥1,200</td>
                                        <td>商场消费</td>
                                    </tr>
                                </tbody>
                            </table>
                        </div>
                    </div>
                    <div class="card-footer bg-white border-0 py-3">
                        <a href="#" class="btn btn-outline-primary">
                            <i class="bi bi-arrow-right-circle me-1"></i> 查看全部交易记录
                        </a>
                    </div>
                </div>
            </div>
            
            <div class="col-md-4">
                <div class="card border-0 shadow-sm h-100">
                    <div class="card-header bg-white border-0 py-3">
                        <h5 class="mb-0"><i class="bi bi-pie-chart me-2"></i> 账户类型分布</h5>
                    </div>
                    <div class="card-body">
                        <canvas id="accountChart" height="250"></canvas>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
    <script>
        // 账户类型分布图
        const ctx = document.getElementById('accountChart').getContext('2d');
        const accountChart = new Chart(ctx, {
            type: 'doughnut',
            data: {
                labels: ['活期存款', '定期存款', '定活两便', '零存整取'],
                datasets: [{
                    data: [45, 30, 15, 10],
                    backgroundColor: [
                        '#1a2a6c',
                        '#b21f1f',
                        '#fdbb2d',
                        '#1a936f'
                    ],
                    borderWidth: 0
                }]
            },
            options: {
                responsive: true,
                maintainAspectRatio: false,
                plugins: {
                    legend: {
                        position: 'bottom',
                        labels: {
                            padding: 20,
                            font: {
                                size: 13
                            }
                        }
                    },
                    tooltip: {
                        callbacks: {
                            label: function(context) {
                                return `${context.label}: ${context.parsed}%`;
                            }
                        }
                    }
                },
                cutout: '65%'
            }
        });
        
        // 实时更新时间
        function updateTime() {
            const now = new Date();
            const timeString = now.toLocaleTimeString('zh-CN', {hour: '2-digit', minute:'2-digit'});
            document.querySelector('.header h4').textContent = `管理员控制面板 · ${timeString}`;
        }
        
        // 初始更新时间
        updateTime();
        // 每分钟更新一次
        setInterval(updateTime, 60000);
    </script>
</body>
</html>